#include <iostream>

using namespace std;

class Produce  //普通商品
{
public:
	virtual void sold(float num)  //售出商品
	{
		
	}
	float cost; //成本
	float price; //售价
	float salenum; //商品卖出的数量
};

class Apple:public Produce
{
public:
	Apple(float _price,float _cost)
	{
		price=_price;
		cost=_cost;
	}
	void sold(float num)
	{
		salenum=num;
		cout<<"苹果卖了 "<<num<<" 斤"<<endl;
	}
};

class Shampo:public Produce
{
public:
	Shampo(float _price,float _cost)
	{
		price=_price;
		cost=_cost;
	}
	void sold(float num)
	{
		salenum=num;
		cout<<"洗发水按瓶卖  "<<num<<"  瓶"<<endl;
	}	
};

class Saler //销售员
{
public:
	Saler(string _name,float _salenum=0.0,float _profit=0.0,float _rate=0.0)
	{
		name=_name;
		allsalenum=_salenum;
		profit=_profit;
		rate=_rate;
	}
	//按照原价卖东西
	void saleProduce(Produce &pro,float _num)  //_num表示你想卖出的数量
	{
		pro.sold(_num);
		//累加销售额和总的利润
		allsalenum+=(pro.price*pro.salenum);
		profit+=((pro.price-pro.cost)*pro.salenum);
	}
	//按照折扣卖东西
	void saleProduce(Produce &pro,float _discount,float _num) //_num表示你想卖出的数量
	{
		discount = _discount;
		pro.sold(_num);
		//累加销售额和总的利润
		allsalenum+=(pro.price * discount / 10)*pro.salenum;  //打完折之后的价格
		profit+=(pro.price * discount / 10 - pro.cost)*pro.salenum;  //打完折之后利润
	}
	void show() const //显示售货员业绩
	{
		cout<<name<<"卖出了"<<allsalenum<<"  "<<"利润是:"<<profit<<endl;
	}
private:
	string name; //销售员名字
	float allsalenum; //总的销售额
	float profit; //总的利润
	float rate; //利润率
	int discount; //折扣  1就一折
};


int main()
{
	//定义三个销售员
	Saler saler1("jack");
	Saler saler2("Rose");
	Saler saler3("bill");
	
	//定义苹果的对象
	Apple hongfushi(7.5,2.5);
	//定义洗发水对象
	Shampo haifeisi(30,10);
	
	//按照原价卖出苹果
	saler1.saleProduce(hongfushi,2.5);  //卖出了2.5斤红富士
	saler1.saleProduce(haifeisi,2); //卖出了两瓶海飞丝
	//显示一下业绩
	saler1.show();
}